package com.clkj.xiuzheng.dao;

import com.clkj.xiuzheng.pojo.OutStockItem;
import com.clkj.xiuzheng.pojo.Product;
import com.clkj.xiuzheng.pojo.ProductStock;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

@Service
public interface InStockItemMapper extends Mapper<OutStockItem>, MySqlMapper<OutStockItem> {
    @Select("select a.*,b.product_name,b.format_name,c.warehouse_name,d.factory_name  from t_cl_outStockItem a " +
            "left join t_cl_product b on a.product_id = b.product_id " +
            "left join t_cl_warehouse c on a.warehouse_id = c.warehouse_id " +
            "left join t_cl_factory d on a.factory_id  = d.factory_id   where a.out_id = #{intoId} and a.item_flag = 0")
    List<OutStockItem> selectAllById(@Param("intoId") Integer intoId);


    @Update("update t_cl_intoStock set apply_status = 1 where into_id = #{intoId}")
    void updateApplyStatus(@Param("intoId")Integer intoId);

    @Select("select * from t_cl_product where product_id = #{productId} ")
    Product selectProductByProductIdAndBarCode(@Param("productId") Integer productId);

}
